package com.ssrs.platform.code;

import com.ssrs.framework.extend.annotation.ExtendItem;
import com.ssrs.platform.FixedCodeType;
import com.ssrs.platform.PlatformPlugin;
import com.ssrs.platform.extend.CodeService;

/**
 * 配置项控件类型
 *
 * @author ssrs
 */
@ExtendItem(
        plugin = PlatformPlugin.class,
        extendService = CodeService.class,
        description = "配置项控件类型代码项"
)
public class ControlType extends FixedCodeType {
    public static final String CODETYPE = "ControlType";

    public static final String TEXT = "Text";
    public static final String PASSWORD = "Password";
    public static final String SELECTOR = "Select";
    public static final String TEXTAREA = "TextArea";
    public static final String RADIO = "Radio";
    public static final String CHECKBOX = "Checkbox";
    public static final String DATESELECTOR = "Date";
    public static final String DATETIMESELECTOR = "DateTime";
    public static final String TIMESELECTOR = "Time";

    public ControlType() {
        super(CODETYPE, "控件类型", true, false);
        addFixedItem(ControlType.CHECKBOX, "多选框", null);
        addFixedItem(ControlType.DATESELECTOR, "日期选择框", null);
        addFixedItem(ControlType.DATETIMESELECTOR, "日期时间选择框", null);
        addFixedItem(ControlType.RADIO, "单选框", null);
        addFixedItem(ControlType.SELECTOR, "下拉框", null);
        addFixedItem(ControlType.TEXT, "输入框", null);
        addFixedItem(ControlType.PASSWORD, "密码输入框", null);
        addFixedItem(ControlType.TEXTAREA, "多行文本框", null);
    }

    public boolean isText(String type) {
        return TEXT.equals(type);
    }

    public boolean isPassword(String type) {
        return PASSWORD.equals(type);
    }

    public boolean isSelector(String type) {
        return SELECTOR.equals(type);
    }

    public boolean isTextArea(String type) {
        return TEXTAREA.equals(type);
    }

    public boolean isRadio(String type) {
        return RADIO.equals(type);
    }

    public boolean isCheckbox(String type) {
        return CHECKBOX.equals(type);
    }

    public boolean isDateSelector(String type) {
        return DATESELECTOR.equals(type);
    }

    public boolean isDateTimeSelector(String type) {
        return DATETIMESELECTOR.equals(type);
    }
}

